import { defineStore } from "pinia";
import { getHotSuggests, getHomeCategories, getHouseList } from "../../services/modules/homeRequest";
// home数据管理
export default defineStore("home", {
    // 数据
    state: () => ({
        hotSuggests: [],
        categories: [],
        houseList: [],
        currentPage: 1  // 页面页数
    }),
    // 操作
    actions: {
        async fetchHotSuggestsData() {
            const res = await getHotSuggests()
            this.hotSuggests = res.data
        },
        async fetchHomeCategoriesData() {
            const res = await getHomeCategories()
            this.categories = res.data
        },
        async fetchHouseListData() {
            const res = await getHouseList(this.currentPage)
            this.houseList.push(...res.data)
            this.currentPage++
        }
    }
})